<?php
/*
 * Get information about a user.
 */

// authenticate user first
F3::call('authentication.php');
if (F3::exists('auth_error'))
{
  // authentication failed
  return;
}

// get user information
$param = array('1' => F3::get('SESSION.user_id'));
$result = DB::sql("SELECT id, email, fname, lname, nickname, gender, dob, SelfDescription FROM user WHERE id=?", $param);
$response = array();
foreach ($result as $row) {
	$response['email'] = $row['email'];
	$response['fname'] = $row['fname'];
	$response['lname'] = $row['lname'];
	$response['nickname'] = $row['nickname'];
	$response['gender'] = $row['gender'];
	$response['dob'] = $row['dob'];
	$response['SelfDescription'] = $row['SelfDescription'];
}

header('HTTP/1.1 200');
header("Content-Type: application/json");
echo json_encode($response);

?>
